<?php

/**
 * This is the model class for table "worker".
 *
 * The followings are the available columns in table 'worker':
 * @property string $worker_id
 * @property string $mobile
 * @property string $password
 * @property string $real_name
 * @property integer $gender
 * @property string $avatar
 * @property string $introduce
 * @property integer $born_year
 * @property string $region
 * @property string $create_time
 * @property string $type_id
 * @property integer $is_delete
 * @property string $update_time
 * @property string $session_id
 * @property integer $is_verify
 * @property string $idcard
 * @property string $pic_idcard
 * @property double $starnum
 * @property double $price
 * @property string $worker_num
 * @property string $type_name
 * @property integer $work_year
 * @property string $reason
 * @property double $balance
 * @property double $balance_withdrawing
 * @property double $balacan_cash
 * @property double $income_order
 * @property double $income_platform
 * @property double $income_purse
 * @property integer $check_in_count
 * @property string $check_in_day
 * @property string $rating_id
 * @property string $rating_name
 * @property double $rating_total
 * @property double $rating_avg_quality
 * @property double $rating_avg_efficiency
 * @property double $rating_avg_satisfaction
 * @property double $rating_avg_manners
 * @property integer $rating_num
 * @property double $rating_avg
 * @property string $construct_pic_list
 * @property string $service_content
 * @property double $distance
 * @property double $lat
 * @property double $lng
 * @property string $created_by
 * @property string $updated_by
 */
class Worker extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Worker the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'worker';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('gender, born_year, is_delete, is_verify, work_year, check_in_count, rating_num', 'numerical', 'integerOnly'=>true),
			array('starnum, price, balance, balance_withdrawing, balacan_cash, income_order, income_platform, income_purse, rating_total, rating_avg_quality, rating_avg_efficiency, rating_avg_satisfaction, rating_avg_manners, rating_avg, distance, lat, lng', 'numerical'),
			array('mobile', 'length', 'max'=>15),
			array('password', 'length', 'max'=>50),
			array('real_name, region, type_id, session_id, idcard, worker_num, type_name, reason, rating_name, created_by, updated_by', 'length', 'max'=>255),
			array('rating_id', 'length', 'max'=>20),
			array('avatar, introduce, create_time, update_time, pic_idcard, check_in_day, construct_pic_list, service_content', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('worker_id, mobile, password, real_name, gender, avatar, introduce, born_year, region, create_time, type_id, is_delete, update_time, session_id, is_verify, idcard, pic_idcard, starnum, price, worker_num, type_name, work_year, reason, balance, balance_withdrawing, balacan_cash, income_order, income_platform, income_purse, check_in_count, check_in_day, rating_id, rating_name, rating_total, rating_avg_quality, rating_avg_efficiency, rating_avg_satisfaction, rating_avg_manners, rating_num, rating_avg, construct_pic_list, service_content, distance, lat, lng, created_by, updated_by', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'worker_id' => 'Worker',
			'mobile' => 'Mobile',
			'password' => 'Password',
			'real_name' => 'Real Name',
			'gender' => 'Gender',
			'avatar' => 'Avatar',
			'introduce' => 'Introduce',
			'born_year' => 'Born Year',
			'region' => 'Region',
			'create_time' => 'Create Time',
			'type_id' => 'Type',
			'is_delete' => 'Is Delete',
			'update_time' => 'Update Time',
			'session_id' => 'Session',
			'is_verify' => 'Is Verify',
			'idcard' => 'Idcard',
			'pic_idcard' => 'Pic Idcard',
			'starnum' => 'Starnum',
			'price' => 'Price',
			'worker_num' => 'Worker Num',
			'type_name' => 'Type Name',
			'work_year' => 'Work Year',
			'reason' => 'Reason',
			'balance' => 'Balance',
			'balance_withdrawing' => 'Balance Withdrawing',
			'balacan_cash' => 'Balacan Cash',
			'income_order' => 'Income Order',
			'income_platform' => 'Income Platform',
			'income_purse' => 'Income Purse',
			'check_in_count' => 'Check In Count',
			'check_in_day' => 'Check In Day',
			'rating_id' => 'Rating',
			'rating_name' => 'Rating Name',
			'rating_total' => 'Rating Total',
			'rating_avg_quality' => 'Rating Avg Quality',
			'rating_avg_efficiency' => 'Rating Avg Efficiency',
			'rating_avg_satisfaction' => 'Rating Avg Satisfaction',
			'rating_avg_manners' => 'Rating Avg Manners',
			'rating_num' => 'Rating Num',
			'rating_avg' => 'Rating Avg',
			'construct_pic_list' => 'Construct Pic List',
			'service_content' => 'Service Content',
			'distance' => 'Distance',
			'lat' => 'Lat',
			'lng' => 'Lng',
			'created_by' => 'Created By',
			'updated_by' => 'Updated By',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('worker_id',$this->worker_id,true);
		$criteria->compare('mobile',$this->mobile,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('real_name',$this->real_name,true);
		$criteria->compare('gender',$this->gender);
		$criteria->compare('avatar',$this->avatar,true);
		$criteria->compare('introduce',$this->introduce,true);
		$criteria->compare('born_year',$this->born_year);
		$criteria->compare('region',$this->region,true);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('type_id',$this->type_id,true);
		$criteria->compare('is_delete',$this->is_delete);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('session_id',$this->session_id,true);
		$criteria->compare('is_verify',$this->is_verify);
		$criteria->compare('idcard',$this->idcard,true);
		$criteria->compare('pic_idcard',$this->pic_idcard,true);
		$criteria->compare('starnum',$this->starnum);
		$criteria->compare('price',$this->price);
		$criteria->compare('worker_num',$this->worker_num,true);
		$criteria->compare('type_name',$this->type_name,true);
		$criteria->compare('work_year',$this->work_year);
		$criteria->compare('reason',$this->reason,true);
		$criteria->compare('balance',$this->balance);
		$criteria->compare('balance_withdrawing',$this->balance_withdrawing);
		$criteria->compare('balacan_cash',$this->balacan_cash);
		$criteria->compare('income_order',$this->income_order);
		$criteria->compare('income_platform',$this->income_platform);
		$criteria->compare('income_purse',$this->income_purse);
		$criteria->compare('check_in_count',$this->check_in_count);
		$criteria->compare('check_in_day',$this->check_in_day,true);
		$criteria->compare('rating_id',$this->rating_id,true);
		$criteria->compare('rating_name',$this->rating_name,true);
		$criteria->compare('rating_total',$this->rating_total);
		$criteria->compare('rating_avg_quality',$this->rating_avg_quality);
		$criteria->compare('rating_avg_efficiency',$this->rating_avg_efficiency);
		$criteria->compare('rating_avg_satisfaction',$this->rating_avg_satisfaction);
		$criteria->compare('rating_avg_manners',$this->rating_avg_manners);
		$criteria->compare('rating_num',$this->rating_num);
		$criteria->compare('rating_avg',$this->rating_avg);
		$criteria->compare('construct_pic_list',$this->construct_pic_list,true);
		$criteria->compare('service_content',$this->service_content,true);
		$criteria->compare('distance',$this->distance);
		$criteria->compare('lat',$this->lat);
		$criteria->compare('lng',$this->lng);
		$criteria->compare('created_by',$this->created_by,true);
		$criteria->compare('updated_by',$this->updated_by,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}